#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef enum Day Day;

enum Day{
    Monday,
    Tuesday,
    Wednesday,
    Thursday,
    Friday,
    Saturday,
    Sunday
};

void day_set_string(Day *thisc, char *text);    //通过字符串赋值
void day_set_int(Day *thisc, int val);          //通过整数赋值
void day_display(Day thisc);                    //显示

int main()
{
    Day day = 0;
    char buf[128] = 0;

    printf("Enter:");
    scanf("%s", buf);

    day_set_string(&day, buf);
    day_display(day);

    day_set_int(&day, 5);
    day_display(day);
    return 0;
}

void day_set_string(Day *thisc, char *text)
{
    if (!text) return;

    else if (!strcmp(text, "Monday"))       *thisc = 0;
    else if (!strcmp(text, "Tuesday"))      *thisc = 1;
    else if (!strcmp(text, "Wednesday"))    *thisc = 2;
    else if (!strcmp(text, "Thursday"))     *thisc = 3;
    else if (!strcmp(text, "Friday"))       *thisc = 4;
    else if (!strcmp(text, "Saturday"))     *thisc = 5;
    else if (!strcmp(text, "Sunday"))       *thisc = 6;
}

void day_set_int(Day *thisc, int val)
{
    *thisc = val;
}

void day_display(Day thisc)
{
    switch (thisc)
    {
    case Monday:
        printf("Monday\n");
        break;
    case Tuesday:
        printf("Tuesday\n");
        break;
    case Wednesday:
        printf("Wednesday\n");
        break;
    case Thursday:
        printf("Thursday\n");
        break;
    case Friday:
        printf("Friday\n");
        break;
    case Saturday:
        printf("Saturday\n");
        break;
    case Sunday:
        printf("Sunday\n");
        break;
    
    default:
        break;
    }
}

